<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$system['name']}后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <style>
        .layui-form-pane .layui-form-label {
            width: 110px;
            padding: 8px 15px;
            height: 38px;
            line-height: 20px;
            border-width: 0;
            border-style: none;
            border-radius: 2px 0 0 2px;
            text-align: center;
            background-color: #FBFBFB;
            overflow: hidden;
            box-sizing: border-box;
        }

    </style>
</head>
<body class="skin-<?php if(!empty($_COOKIE['skin'])){echo $_COOKIE['skin'];}else{echo '0';setcookie('skin','0');}?>">
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">

    <form class="layui-form layui-form-pane">
        <input type="hidden" value="{$result.id}" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">客户手机号</label>
            <div class="layui-input-block">
                <input type="text" id="cphone" name="cphone" lay-verify="required" placeholder="请输入客户手机号" class="layui-input" value="{$result.cphone}" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <label class="" id="checklabel"></label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">订单号</label>
            <div class="layui-input-block">
                <input type="text" id="orderno" name="orderno" lay-verify="required|orderno_unqiue"  placeholder="请输入客户订单号" class="layui-input" value="{$result.orderno}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-block">
                <input type="text" readonly id="cname" name="cname" lay-verify="required"  placeholder="请输入客户名称" class="layui-input" value="{$result.cname}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">客户负责人</label>
            <div class="layui-input-block">
                <input type="text" readonly id="pr_user" name="pr_user" lay-verify="required" value="{$result.pr_user}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">业绩</label>
            <div class="layui-input-block">
                <input type="text" id="money" name="money"  placeholder="请输入金额" class="layui-input" value="{$result.money}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回款</label>
            <div class="layui-input-block">
                <input type="text" id="return_money" name="return_money"  placeholder="请输入回款金额" class="layui-input" value="{$result.return_money}">
            </div>
        </div>
        <!--
        <div class="layui-form-item">
            <label class="layui-form-label">运费</label>
            <div class="layui-input-block">
                <input type="text" id="freight" name="freight"  placeholder="请输入运费金额" class="layui-input" value="{$result.freight}">
            </div>
        </div>
        -->
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入备注信息" class="layui-textarea" name="remark">{$result.remark}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn"  lay-submit="" lay-filter="submit">提交审核</button>

            </div>
        </div>

    </form>
</div>
{include file="common/foot"/}

<script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery;
            $(document).on('change','#cphone',function (){
                //重新查找业务员的客户信息
                var custphone = $("#cphone").val();
                $('#cname').val('');
                var url = "{:url('Order/changeyewu')}";
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    data: {'id':{$result.id},'cphone':custphone},
                    url: url ,//url
                    success: function (result) {
                        //console.log(result);//打印服务端返回的数据(调试用)
                        //alert("修改成功");
                        if (result['msg']['code'] == 0) {
                            $('#checklabel').css('color','red');
                        }else{
                            $('#checklabel').css('color','green');
                            $('#cname').val(result['msg']['custname']);
                            $('#pr_user').val(result['msg']['pr_user']);
                            $('#kh_username').val(result['msg']['kh_username']);
                        }
                        $('#checklabel').html(result['msg']['msg']);


                    },
                    error : function() {
                        alert("异常！");
                    }
                });
            });
            form.verify({
                orderno_unqiue : function(value, item) {
                    var checkResult=false;
                    $.ajax({
                        url: "{:url('Order/verify_orderno')}",
                        type: "POST",dataType:"json",
                        data: {orderno:value,'id':{$result.id}},
                        async: false,
                        success: function(res) {
                            if (res.code < 0){
                                checkResult=res.msg;
                            }
                        },
                        error: function() {
                        }
                    });
                    if(checkResult){
                        return checkResult;
                    }
                }
            });
            //监听提交
            form.on('submit(submit)', function(data){
                $.post("{:url('Order/myedit')}",data.field,function (res) {
                    if (res.code == 0){
                        layer.msg(res.msg,{time:1000},function (){
                            window.parent.location.reload();
                        });
                    }else {
                        layer.msg(res.msg,{time:2000});
                    }

                },'json')

                return false;
            });
        });
</script>
</body>
</html>